RAIS  3.2
C:/Projekte/RAIS/Specific Masks/EditFunctionalRoles_New.aspx.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Data;
00030 using System.Configuration;
00031 using System.Collections;
00032 using System.Collections.Generic;
00033 using System.Web;
00034 using System.Web.Security;
00035 using System.Web.UI;
00036 using System.Web.UI.WebControls;
00037 using System.Web.UI.WebControls.WebParts;
00038 using System.Web.UI.HtmlControls;
00039 
00040 using RAIS.Common.UserManagement;
00041 
00042 using DataRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.DataRole>;
00043 using DataRoleAttributes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.DataRoleAttribute>;
00044 using FunctionRoles = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole>;
00045 using FunctionRoleCategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Category>;
00046 using FunctionRoleSubcategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Subcategory>;
00047 using Masks = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Mask>;
00048 using FunctionRoleAttributes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRoleAttribute>;
00049 using UserTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.UserTypeData>;
00050 
00051 namespace RAIS.UI.SpecificMasks
00052 {
00056     public partial class EditFunctionalRoles_New : System.Web.UI.Page
00057     {
00058         enum PageMode
00059         {
00060             viewRoles,
00061             addRole,
00062             editRole
00063         };
00064         string[] accessNames = new string[4];
00065                 //*********************************************************************
00066                 #region Event handlers
00067         protected void Page_PreLoad(object sender, EventArgs e)
00068         {
00069             RAIS.UI.Common.PageManagement.TrimTextBoxValues(this);
00070         }
00081         protected void Page_Load(object sender, EventArgs e)
00082         {
00083                         this.Response.Cache.SetNoStore();
00084                         if (this.CurrentUser == null)
00085                 UI.Common.AccessManagement.SignOut(this);
00086 
00087             if (!this.IsPostBack)
00088             {
00089                 this.BTNdelete.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", RAIS.Common.Messages.DELETE_QUESTION_FUNCTIONAL_ROLE.Replace("'", "\\'")));
00090                 UI.Common.UserManagement.InitializeFunctionalRoles(this);
00091             }
00092 
00093             this.InitializeControls();
00094             this.EnableRemoveButton();
00095 
00096             this.LBLresult.Text = "";
00097 
00098             if (!this.IsPostBack)
00099             {
00100                 this.LBLusername.Text = this.CurrentUser.Name;
00101                 this.CurrentPageMode = PageMode.viewRoles;
00102 
00103                 UI.Common.PageManagement.InitializePage(this, this.TreeView1);
00104 //                              this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest);
00105                                 this.ShowRole();
00106             }
00107             this.FillUpAccessNames();
00108         }
00109         protected void Page_Init(object sender, EventArgs e)
00110         {
00111             //Common.PageManagement.SetScrolableListBox(LBfmrolename, this, true);
00112             Common.PageManagement.SetScrolableListBox(LBfm, this, true);
00113         }
00124         protected void LBfmrolename_SelectedIndexChanged(object sender, EventArgs e)
00125         {
00126             this.EnableDisableEditDelete();
00127             this.ShowRole();
00128         }
00135         protected void BTNadd_Click(object sender, EventArgs e)
00136         {
00137             this.ClearRoleData();
00138             this.CreateTemperaryRole();
00139             this.Modified = true;
00140             this.CurrentPageMode = PageMode.addRole;
00141         }
00148         protected void LBTNlogout_Click(object sender, EventArgs e)
00149         {
00150             UI.Common.AccessManagement.SignOut(this);
00151         }
00159         protected void BTNedit_Click(object sender, EventArgs e)
00160         {
00161             this.CurrentPageMode = PageMode.editRole;
00162             this.EnableRemoveButton();
00163         }
00170         protected void BTNdelete_Click(object sender, EventArgs e)
00171         {
00172             this.DeleteSelectedRole();
00173             this.EnableDisableEditDelete();
00174             this.ShowRole();
00175         }
00183         protected void BTNsave_Click(object sender, EventArgs e)
00184         {
00185             if (this.CurrentPageMode == PageMode.addRole)
00186                 this.AddNewRole();
00187             else
00188                 this.SaveRole();
00189             this.EnableDisableEditDelete();
00190         }
00198         protected void BTNdiscard_Click(object sender, EventArgs e)
00199         {
00200             this.ClearRoleData();
00201             this.EnableRemoveButton();
00202             this.ShowRole();
00203 
00204             this.CurrentPageMode = PageMode.viewRoles;
00205             this.Modified = false;
00206 
00207             this.InitializeControls();
00208             this.EnableDisableControls();
00209         }
00217         protected void BTNfmadd_Click(object sender, EventArgs e)
00218         {
00219             this.AddFunctionRoleAttribute();
00220             this.InitializeControls();
00221             this.EnableRemoveButton();
00222         }
00230         protected void BTNfmremove_Click(object sender, EventArgs e)
00231         {
00232             this.RemoveFunctionRoleAttribute();
00233             this.InitializeControls();
00234             this.EnableRemoveButton();
00235         }
00242         protected void DDLvalidation_SelectedIndexChanged(object sender, EventArgs e)
00243         {
00244             this.SetNewValidationSelection(this.DDLvalidation.SelectedValue);
00245             this.Modified = true;
00246             this.EnableDisableControls();
00247         }
00254         protected void DDLusertype_SelectedIndexChanged(object sender, EventArgs e)
00255         {
00256             this.SetUserTypeToFunctionalRole(this.DDLusertype.SelectedValue);
00257             this.Modified = true;
00258             this.EnableDisableControls();
00259         }
00266         protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
00267         {
00268             UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1);
00269         }
00270         #endregion
00271                 //*********************************************************************
00272                 #region Private helper methods
00273 
00279         void ShowRole()
00280         {
00281             if (this.SelectedRole == null)
00282             {
00283                 ClearRoleData();
00284                 return;
00285             }
00286             else
00287             {
00288                 this.TXTrolename.Text = this.SelectedRole.Name;
00289                 UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole, this.accessNames);
00290                 this.InitializaValidationSelection(this.SelectedRole);
00291                 this.InitializeUserTypesCheckBoxes(this.SelectedRole);
00292                 this.InitializeAccessFlags(this.SelectedRoleAttribute);
00293             }
00294         }
00298         void ClearRoleData()
00299         {
00300             this.TXTrolename.Text = "";
00301             this.LBfm.Items.Clear();
00302 //            this.DDLusertype.SelectedIndex = 0;
00303             this.DDLusertype.SelectedValue = null;
00304             this.DDLvalidation.SelectedIndex = 0;
00305             this.DDLfmcategories.SelectedIndex = 0;
00306             this.DDLfmsubcategories.SelectedIndex = 0;
00307             this.DDLfmmask.SelectedIndex = 0;
00308         }
00314         private void SetCategorySelection(FunctionRoleAttribute roleAttribute)
00315         {
00316             if (roleAttribute != null)
00317             {
00318                 this.DDLfmcategories.SelectedValue = roleAttribute.Category.Name;
00319             }
00320         }
00326         private void SetSubcategorySelection(FunctionRoleAttribute roleAttribute)
00327         {
00328             if (roleAttribute != null)
00329             {
00330                 this.DDLfmsubcategories.SelectedValue = roleAttribute.Subcategory.Name;
00331             }
00332         }
00338         private void SetMaskSelection(FunctionRoleAttribute roleAttribute)
00339         {
00340             if (roleAttribute != null)
00341             {
00342                 this.DDLfmmask.SelectedValue = roleAttribute.Mask.Name;
00343             }
00344         }
00348         private void DeleteSelectedRole()
00349         {
00350             FunctionRole selectedRole = this.SelectedRole;
00351 
00352             if (selectedRole != null)
00353             {
00354                 string returnMessage = "";
00355                 bool success = ApplicationLogicLayer.UserManagement.RemoveFunctionRole(selectedRole, ref returnMessage);
00356                 this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] = null; //for resetting
00357                 UI.Common.UserManagement.InitializeFunctionalRolesListBox(this.LBfmrolename);
00358                 UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole, this.accessNames);
00359                 this.EnableRemoveButton();
00360                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00361                                                                     returnMessage,
00362                                                                     success);
00363             }
00364         }
00368         private void CreateTemperaryRole()
00369         {
00370             FunctionRole tempRole = new FunctionRole();
00371             this.Session[UI.Common.Constants.FUNCTION_ROLE_TEMPORARY_TAG] = tempRole;
00372         }
00377         private bool ConfirmRoleDeletion()
00378         {
00379             return true;
00380         }
00385         private bool SaveRole()
00386         {
00387             string returnMessage = "";
00388             bool success = true;
00389 
00390             if (!this.Modified)
00391             {
00392                 returnMessage = RAIS.Common.Messages.FUNCTION_ROLE_NO_MODIFICATION;
00393                 success = false;
00394             }
00395             else
00396             {
00397                 success = ApplicationLogicLayer.UserManagement.SaveFunctionRole(this.SelectedRole, ref returnMessage);
00398                 if (success)
00399                 {
00400                     this.CurrentPageMode = PageMode.viewRoles;
00401                     this.Modified = false;
00402 
00403                     this.InitializeControls();
00404                     this.EnableDisableControls();
00405                 }
00406             }
00407             RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00408                                                                 returnMessage,
00409                                                                 success);
00410             return success;
00411         }
00416         private bool AddNewRole()
00417         {
00418             string validationMessage = "";
00419             bool success = this.ValidateNewFuncitonalRole(this.TXTrolename.Text, ref validationMessage);
00420 
00421             if (success)
00422             {
00423                 success = ApplicationLogicLayer.UserManagement.AddFunctionRole(this.TXTrolename.Text, ref validationMessage);
00424                 if (success)
00425                 {
00426                     FunctionRole tempRole = this.SelectedRole;
00427                     this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_TEMPORARY_TAG] = null;
00428                     UI.Common.UserManagement.InitializeFunctionalRoles(this);
00429 
00430                     FunctionRoles functionRoles = (FunctionRoles)this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG];
00431                     FunctionRole savedRole = functionRoles[this.TXTrolename.Text];
00432 
00433                     foreach (FunctionRoleAttribute attribute in tempRole.AddedAttributes.Values)
00434                     {
00435                         success = savedRole.AddAttribute(attribute, ref validationMessage);
00436                         if (!success)
00437                             break;
00438                     }
00439 
00440                     savedRole.Validation = FunctionRole.ValidationTypeNamesDictionary[this.DDLvalidation.SelectedValue];
00441 
00442                     UserTypes userTypes = UI.Common.UserManagement.UserTypes;
00443                     if (userTypes.ContainsKey(this.DDLusertype.SelectedValue))
00444                     {
00445                         UserTypeData userType = userTypes[this.DDLusertype.SelectedValue];
00446                         success = savedRole.AddUserType(userType, ref validationMessage);
00447                     }
00448 
00449                     if( success )
00450                         success = ApplicationLogicLayer.UserManagement.SaveFunctionRole(savedRole, ref validationMessage);
00451                 }
00452 
00453                 if (success)
00454                 {
00455                     this.CurrentPageMode = PageMode.viewRoles;
00456                     this.Modified = false;
00457 
00458                     UI.Common.UserManagement.InitializeFunctionalRolesListBox(this.LBfmrolename);
00459                     this.LBfmrolename.SelectedValue = this.TXTrolename.Text;
00460 
00461                     UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole, this.accessNames);
00462 
00463                     this.InitializeControls();
00464                     this.EnableDisableControls();
00465                 }
00466             }
00467             RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00468                                                                 validationMessage,
00469                                                                 success);
00470             return success;
00471         }
00480         bool ValidateNewFuncitonalRole(string roleName, ref string returnMessage)
00481         {
00482             FunctionRoles funcitonRoles = (FunctionRoles)this.Session[UI.Common.Constants.FUNCTION_ROLES_TAG];
00483             if (funcitonRoles.ContainsKey(roleName))
00484             {
00485                 returnMessage = RAIS.Common.Messages.FUNCTION_ROLE_EXISTS;
00486                 return false;
00487             }
00488             else
00489             if (roleName.Length == 0)
00490             {
00491                 returnMessage = RAIS.Common.Messages.NAME_IS_EMTPY;
00492                 return false;
00493             }
00494             else
00495                 return true;
00496         }
00502         private bool SetNewValidationSelection(string newValidation)
00503         {
00504             FunctionRole.ValidationType newSelection = FunctionRole.ValidationTypeNamesDictionary[newValidation];
00505             FunctionRole selectedRole = this.SelectedRole;
00506             if (selectedRole != null)
00507             {
00508                 selectedRole.Validation = newSelection;
00509                 this.EnableDisableControls();
00510 
00511                 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE;
00512 
00513                 //                bool success = ApplicationLogicLayer.UserManagement.SaveFunctionRole(selectedRole, ref returnMessage);
00514 
00515                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00516                                                                     returnMessage,
00517                                                                     true);
00518 
00519             }
00520             return false;
00521         }
00525         private void AddFunctionRoleAttribute()
00526         {
00527             FunctionRole selectedRole = this.SelectedRole;
00528             if (selectedRole != null)
00529             {
00530                 FunctionRoleAttribute functionAttribute = new FunctionRoleAttribute();
00531                 functionAttribute.Category = this.SelectedCategory;
00532                 functionAttribute.Subcategory = this.SelectedSubcategory;
00533                 functionAttribute.Mask = this.SelectedMask;
00534 
00535                 functionAttribute.AccessView = this.CBfmview.Checked;
00536                 functionAttribute.AccessAdd = this.CBfmadd.Checked;
00537                 functionAttribute.AccessEdit = this.CBfmedit.Checked;
00538                 functionAttribute.AccessDelete = this.CBfmdelete.Checked;
00539 
00540                 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE;
00541 
00542                 bool success = this.ValidateNewFunctionRoleAttribute(functionAttribute, ref returnMessage);
00543                 if (success)
00544                 {
00545                     success = selectedRole.AddAttribute(functionAttribute, ref returnMessage);
00546                     this.EnableDisableControls();
00547 
00548                     UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole, this.accessNames);
00549                     this.LBfm.SelectedValue = functionAttribute.ToString();
00550 
00551                 }
00552                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00553                                                                     returnMessage,
00554                                                                     success);
00555             }
00556         }
00557 
00558         private void SetUserTypeToFunctionalRole(string userTypeName)
00559         {
00560             FunctionRole selectedRole = this.SelectedRole;
00561             if (selectedRole != null)
00562             {
00563                 UserTypes userTypes = UI.Common.UserManagement.UserTypes;
00564                 if (userTypes.ContainsKey(userTypeName))
00565                 {
00566                     UserTypeData userType = userTypes[userTypeName];
00567 
00568                     string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE;
00569                     selectedRole.UserTypes.Clear();
00570 
00571                     bool success = selectedRole.AddUserType(userType, ref returnMessage);
00572 
00573                     this.EnableDisableControls();
00574 
00575                     RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00576                                                                         returnMessage,
00577                                                                         success);
00578                 }
00579             }
00580         }
00584         private void RemoveFunctionRoleAttribute()
00585         {
00586             FunctionRole selectedRole = this.SelectedRole;
00587             if (selectedRole != null)
00588             {
00589                 FunctionRoleAttribute selectedAttribute = this.SelectedRoleAttribute;
00590 
00591                 try
00592                 {
00593                     this.InitializeAccessFlags(     selectedAttribute);
00594                     this.SetCategorySelection(      selectedAttribute);
00595                     this.SetSubcategorySelection(   selectedAttribute);
00596                     this.SetMaskSelection(          selectedAttribute);
00597                 }
00598                 catch
00599                 {
00600 
00601                 }
00602 
00603                 string returnMessage = RAIS.Common.Messages.MODIFICATION_PRESS_SAVE;
00604 
00605                 bool success = selectedRole.RemoveAttribute(selectedAttribute, ref returnMessage);
00606                 this.EnableDisableControls();
00607 
00608                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, returnMessage, success);
00609             }
00610         }
00619         bool ValidateNewFunctionRoleAttribute(FunctionRoleAttribute newFuncitonRoleAttribute, ref string returnMessage)
00620         {
00621             FunctionRole funcitonRole = this.SelectedRole;
00622             if (funcitonRole == null)
00623             {
00624                 returnMessage = RAIS.Common.Messages.FUNCTION_ROLE_DOES_NOT_EXIST;
00625                 return false;
00626             }
00627             else
00628             {
00629                 return funcitonRole.ValidateNewAttribute(newFuncitonRoleAttribute, ref returnMessage);
00630             }
00631         }
00635         private void EnableRemoveButton()
00636         {
00637             this.BTNfmremove.Enabled =  this.LBfm.Items.Count > 0 &&
00638                                         this.SelectedRole != null &&
00639                                         this.SelectedRole.Attributes.ContainsKey(this.LBfm.SelectedValue) &&
00640                                         this.CurrentPageMode != PageMode.viewRoles;
00641         }
00645         private void InitializeAccessFlags(FunctionRoleAttribute attribute)
00646         {
00647             if (attribute != null)
00648             {
00649                 this.CBfmadd.Checked = attribute.AccessAdd;
00650                 this.CBfmdelete.Checked = attribute.AccessDelete;
00651                 this.CBfmedit.Checked = attribute.AccessEdit;
00652                 this.CBfmview.Checked = attribute.AccessView;
00653             }
00654             else
00655             {
00656                 this.CBfmadd.Checked = false;
00657                 this.CBfmdelete.Checked = false;
00658                 this.CBfmedit.Checked = false;
00659                 this.CBfmview.Checked = false;
00660             }
00661         }
00665         private void FillUpAccessNames()
00666         {
00667             bool initializeList = this.accessNames[0] == null;
00668 
00669             this.accessNames[0] = this.CBfmview.Text;
00670             this.accessNames[1] = this.CBfmadd.Text;
00671             this.accessNames[2] = this.CBfmedit.Text;
00672             this.accessNames[3] = this.CBfmdelete.Text;
00673 
00674             if( initializeList )
00675                 UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole, this.accessNames);
00676         }
00680         private void InitializaValidationSelection(FunctionRole functionalRole)
00681         {
00682             if (functionalRole != null)
00683             {
00684                 this.DDLvalidation.SelectedValue = functionalRole.ValidationData.VisibleName;
00685             }
00686         }
00690         private void InitializeUserTypesCheckBoxes(FunctionRole functionalRole)
00691         {
00692             if (functionalRole != null && functionalRole.UserTypes != null)
00693             {
00694                 foreach (UserTypeData userTypeData in functionalRole.UserTypes.Values)
00695                 {
00696                     this.DDLusertype.SelectedValue = userTypeData.VisibleName;
00697                     break;
00698                 }
00699             }
00700         }
00704         private void InitializeControls()
00705         {
00706             UI.Common.UserManagement.InitializeFunctionalRolesListBox(this.LBfmrolename);
00707             UI.Common.UserManagement.InitializeValidationList(this.DDLvalidation);
00708             UI.Common.UserManagement.InitializeUserTypeList(this.DDLusertype);
00709             UI.Common.UserManagement.InitializeCategoriesList(this.DDLfmcategories, this.SelectedRole);
00710 
00711             UI.Common.UserManagement.InitializeSubcategoriesList(this.DDLfmsubcategories,
00712                                                                     this.SelectedCategory,
00713                                                                     this.SelectedRole);
00714 
00715             UI.Common.UserManagement.InitializeMasksList(this.DDLfmmask,
00716                                                                     this.SelectedCategory,
00717                                                                     this.SelectedSubcategory,
00718                                                                     this.SelectedRole);
00719 
00720             UI.Common.UserManagement.InitializeFuncitonRoleAttributesList(this.LBfm, this.SelectedRole, this.accessNames);
00721         }
00725         private void EnableDisableControls()
00726         {
00727             this.LBfmrolename.Enabled = this.CurrentPageMode == PageMode.viewRoles;
00728 
00729             this.LBfm.Enabled       = this.CurrentPageMode != PageMode.viewRoles;
00730             this.CBfmview.Enabled   = this.CurrentPageMode != PageMode.viewRoles;
00731             this.CBfmedit.Enabled   = this.CurrentPageMode != PageMode.viewRoles;
00732             this.CBfmadd.Enabled    = this.CurrentPageMode != PageMode.viewRoles;
00733             this.CBfmdelete.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00734 
00735             this.DDLusertype.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00736 
00737             this.DDLfmcategories.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00738             this.DDLfmsubcategories.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00739             this.DDLfmmask.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00740 
00741             this.DDLvalidation.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00742 
00743             this.BTNfmadd.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00744             this.BTNfmremove.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00745 
00746             this.BTNadd.Enabled  = this.CurrentPageMode == PageMode.viewRoles;
00747             this.BTNsave.Enabled = this.Modified;
00748             this.BTNdiscard.Enabled = this.CurrentPageMode != PageMode.viewRoles;
00749 
00750             this.EnableDisableEditDelete();
00751 
00752             this.TXTrolename.Enabled = this.CurrentPageMode == PageMode.addRole;
00753 
00754             UI.Common.UserManagement.EnableCommonControls(this, this.CurrentPageMode == PageMode.viewRoles);
00755 
00756             this.LBLadmin.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT;
00757 
00758             if( this.Modified )
00759                 this.BTNdiscard.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", RAIS.Common.Messages.DISCARD_QUESTION_ROLE.Replace("'", "\\'")));
00760             else
00761                 this.BTNdiscard.Attributes.Remove("onclick");
00762         }
00766         void EnableDisableEditDelete()
00767         {
00768             this.BTNedit.Enabled = this.CurrentPageMode == PageMode.viewRoles && this.SelectedRole != null;
00769             this.BTNdelete.Enabled = this.CurrentPageMode == PageMode.viewRoles && this.SelectedRole != null;
00770         }
00771         #endregion
00772                 //*********************************************************************
00773                 #region Private helper properties
00774 
00777         private FunctionRole SelectedRole
00778         {
00779             get
00780             {
00781                 if (this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_TEMPORARY_TAG] != null)
00782                     return (FunctionRole)this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_TEMPORARY_TAG];
00783                 else
00784                 {
00785                     FunctionRoles functionRoles = (FunctionRoles)this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG];
00786                     if (functionRoles != null && functionRoles.ContainsKey(this.LBfmrolename.SelectedValue))
00787                         return functionRoles[this.LBfmrolename.SelectedValue];
00788                     else
00789                         return null;
00790                 }
00791             }
00792         }
00796         private FunctionRole.Category SelectedCategory
00797         {
00798             get
00799             {
00800                 FunctionRoleCategories categories = (FunctionRoleCategories)this.Session[UI.Common.Constants.FUNCTION_ROLE_CATEGORIES_TAG];
00801                 if (categories != null && categories.ContainsKey(this.DDLfmcategories.SelectedValue))
00802                     return categories[this.DDLfmcategories.SelectedValue];
00803                 else
00804                     return null;
00805             }
00806         }
00810         private FunctionRole.Subcategory SelectedSubcategory
00811         {
00812             get
00813             {
00814                 FunctionRoleSubcategories subcategories = (FunctionRoleSubcategories)this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_SUBCATEGORIES_TAG];
00815                 if (subcategories != null && subcategories.ContainsKey(this.DDLfmsubcategories.SelectedValue))
00816                     return subcategories[this.DDLfmsubcategories.SelectedValue];
00817                 else
00818                     return null;
00819             }
00820         }
00824         private Mask SelectedMask
00825         {
00826             get
00827             {
00828                 Masks masks = (Masks)this.Session[RAIS.UI.Common.Constants.MASKS_TAG];
00829                 if (masks != null && masks.ContainsKey(this.DDLfmmask.SelectedValue))
00830                     return masks[this.DDLfmmask.SelectedValue];
00831                 else
00832                     return null;
00833             }
00834         }
00838         private FunctionRoleAttribute SelectedRoleAttribute
00839         {
00840             get
00841             {
00842                 FunctionRole selectedRole = this.SelectedRole;
00843                 if (selectedRole != null && selectedRole.Attributes.ContainsKey(this.LBfm.SelectedValue))
00844                     return selectedRole.Attributes[this.LBfm.SelectedValue];
00845                 else
00846                     return null;
00847             }
00848         }
00852         PageMode CurrentPageMode
00853         {
00854             get
00855             {
00856                 if (this.Session[UI.Common.Constants.FUNCTION_ROLE_EDIT_MODE_TAG] != null)
00857                 {
00858                     return (PageMode)this.Session[UI.Common.Constants.FUNCTION_ROLE_EDIT_MODE_TAG];
00859                 }
00860                 else
00861                     return PageMode.viewRoles;
00862             }
00863             set
00864             {
00865                 string message;
00866                 switch (value)
00867                 {
00868                     case PageMode.addRole: message = RAIS.UI.Common.Constants.ADDING_NEW_FUNCTIONAL_ROLE; break;
00869                     case PageMode.editRole: message = RAIS.UI.Common.Constants.EDITTING_EXISTING_FUNCTIONAL_ROLE; break;
00870 
00871                     default:
00872                         this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_TEMPORARY_TAG] = null;
00873                         message = ""; 
00874                         break;
00875                 }
00876                 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult, message, true);
00877                 this.Session[UI.Common.Constants.FUNCTION_ROLE_EDIT_MODE_TAG] = value;
00878                 this.EnableDisableControls();
00879             }
00880         }
00884         bool Modified
00885         {
00886             get
00887             {
00888                 if (this.SelectedRole != null)
00889                     return this.SelectedRole.Modified;
00890                 else
00891                     return false;
00892             }
00893             set
00894             {
00895                 if (this.SelectedRole != null)
00896                     this.SelectedRole.Modified = value;
00897 
00898                 if (!value)
00899                 {
00900                     this.Session[RAIS.UI.Common.Constants.FUNCTION_ROLES_TAG] = null;
00901                 }
00902             }
00903         }
00907         protected UserData CurrentUser
00908         {
00909             get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; }
00910         }
00911         #endregion
00912     }
00913 }